home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.uv.es
/
2014.11.ftp.uv.es.tar
/
ftp.uv.es
/
pub
/
mirror
/
MailDrop
/
plug-ins
/
SamplePlugInProjects.hqx
/
Sample Plug-in Projects
/
Current Bear ID
/
Current Bear ID.c
next >
Wrap
C/C++ Source or Header
|
1997-01-08
|
2KB
|
103 lines
#include <SetupA4.h>
#include <A4Stuff.h>
#include "Mail Drop PlugIns.h"
#include <string.h>
void GetPreferencesFolder(short *vRefNumP, long *dirIDP);
pascal OSErr main(short selector, MailDropPlugInPBPtr plugInPBPtr, void *plugInData)
{
MailDropDefaultParam *pb;
long oldA4;
OSErr err;
short refNum;
short vRefNum;
long dirID;
FSSpec spec;
Handle strHandle;
pb = (MailDropDefaultParam *)plugInPBPtr;
if (pb == nil) return errNullParamBlock;
if (pb->type != 'Dflt') return errWrongPlugInType;
oldA4 = SetCurrentA4();
RememberA4();
err = noErr;
switch (selector) {
case selectorPrepare:
case selectorFinish:
break;
case selectorDefaultGetInfo:
GetPreferencesFolder(&vRefNum, &dirID);
err = FSMakeFSSpec(vRefNum, dirID, "\pCurrent Bear ID", &spec);
if (err != noErr) break;
refNum = FSpOpenResFile(&spec, fsRdPerm);
if ((refNum == -1) || (ResError() != noErr)) {
err = ResError();
break;
if (err != noErr) break;
}
strHandle = Get1Resource('STR ', 128);
if (strHandle != nil) {
if (GetHandleSize(strHandle) < 80) {
BlockMoveData(*strHandle, pb->Username, GetHandleSize(strHandle));
p2cstr((StringPtr)pb->Username);
}
ReleaseResource(strHandle);
}
// These next two aren't really supported by this plug-in because the information
// isn't in the "Current Bear ID" file.
/*
strHandle = Get1Resource('STR ', 129);
if (strHandle != nil) {
if (GetHandleSize(strHandle) < 80) {
BlockMoveData(*strHandle, pb->Password, GetHandleSize(strHandle));
p2cstr((StringPtr)pb->Password);
}
ReleaseResource(strHandle);
}
strHandle = Get1Resource('STR ', 130);
if (strHandle != nil) {
if (GetHandleSize(strHandle) < 256) {
BlockMoveData(*strHandle, pb->IMAPServer, GetHandleSize(strHandle));
p2cstr((StringPtr)pb->IMAPServer);
}
ReleaseResource(strHandle);
}
*/
CloseResFile(refNum);
break;
default:
err = errInvalidSelector;
break;
}
SetA4(oldA4);
return err;
}
void GetPreferencesFolder(short *vRefNumP, long *dirIDP)
{
if (FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, vRefNumP, dirIDP) != noErr) {
*vRefNumP = 0;
*dirIDP = 0;
}
}